# import pulp
# # 定义摄入数据
# intake_data = {
#     "能量(kcal)": {"下限": 2400, "上限": 2666.72, "实际摄入": 2666.72},
#     "蛋白质(g)": {"下限": 60.00, "上限": 90.00, "实际摄入": 88.24},
#     "脂肪(g)": {"下限": 53.33, "上限": 113.24, "实际摄入": 113.24},
#     "膳食纤维(g)": {"下限": 25.00, "上限": 48.08, "实际摄入": 48.08},
#     "碳水化合物(g)": {"下限": 300.00, "上限": 390.00, "实际摄入": 323.25}
# }
#
# # 计算每个Si值并打印
# Si_values = {}
# for nutrient, data in intake_data.items():
#     lower_limit = data["下限"]
#     upper_limit = data["上限"]
#     actual_intake = data["实际摄入"]
#     Si = (actual_intake - lower_limit) / (upper_limit - lower_limit) * 100
#     Si_values[nutrient] = Si
#     print(f"男大学生{nutrient}的Si值为: {Si:.2f}")
#
# # 计算每个Pi值并求和
# Pi_sum = 0
# for nutrient, Si in Si_values.items():
#     Pi = Si * 0.2
#     Pi_sum += Pi
#
# print("男大学生DQI膳食质量指数为:", round(Pi_sum, 2))



# 定义摄入数据
intake_data = {
    "能量(kcal)": {"下限": 0, "上限": 2000, "实际摄入": 1413},
    "蛋白质(g)": {"下限": 47.50, "上限": 71.25, "实际摄入": 52.20},
    "脂肪(g)": {"下限": 42.22, "上限": 63.33, "实际摄入": 46.59},
    "膳食纤维(g)": {"下限": 0, "上限": 35.50, "实际摄入": 12.91},
    "碳水化合物(g)": {"下限": 0, "上限": 308.75, "实际摄入": 196.23}
}

# 计算每个Si值并打印
Si_values = {}
for nutrient, data in intake_data.items():
    lower_limit = data["下限"]
    upper_limit = data["上限"]
    actual_intake = data["实际摄入"]
    Si = (actual_intake - lower_limit) / (upper_limit - lower_limit) * 100
    Si_values[nutrient] = round(Si, 2)
    print(f"女大学生{nutrient}的Si值为: {Si_values[nutrient]}")

# 计算每个Pi值并求和
Pi_sum = 0
for nutrient, Si in Si_values.items():
    Pi = Si * 0.2
    Pi_sum += Pi

print("女大学生指标Pi的总和为:", round(Pi_sum, 2))
